package com.zr.action;

import java.io.IOException;
import java.io.PrintWriter;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts2.interceptor.ServletResponseAware;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import com.zr.service.PointService;

import net.sf.json.JSONObject;

@Controller
@Scope(value="prototype")
public class Point implements ServletResponseAware{
	private int page;
	private int rows;
	private HttpServletResponse resp;
	
	
	public int getPage(){
		return page;
	}

	public void setPage(int page) {
		this.page = page;
	}

	public int getRows() {
		return rows;
	}

	public void setRows(int rows) {
		this.rows = rows;
	}

	@Resource 
	private PointService pointservice;
	
	public void pointSearch(){
		resp.setCharacterEncoding("utf8");
		try {
			PrintWriter pw = resp.getWriter();
			JSONObject j = pointservice.findAllPoint(page, rows);
			pw.write(j.toString());
			pw.flush();
			pw.close();
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
	@Override
	public void setServletResponse(HttpServletResponse response) {
		this.resp=response;
	}


}
